package com.qf.smsplatform.webmaster.sqlprovider;


import com.qf.smsplatform.webmaster.pojo.TSmsTemplate;
import org.springframework.util.ObjectUtils;

public class SmsSqlProvider {

    public String getFindByxxx(TSmsTemplate tSmsTemplate) {
        StringBuilder stringBuilder = new StringBuilder("SELECT * FROM t_sms_template ");
        StringBuilder builder = new StringBuilder();
        if (tSmsTemplate.getCreater() != null) {
            builder.append("creater = #{creater}");
        }
        if (tSmsTemplate.getStatus() != null) {
            if (builder.length() != 0) {
                builder.append("and status = #{status}");
            } else {
                builder.append(" status = #{status}");
            }
        }

        String tiaojian = builder.toString();

        if (!ObjectUtils.isEmpty(tiaojian)) {
            stringBuilder.append("where ");
            stringBuilder.append(tiaojian);
        }

        return stringBuilder.toString();
    }
}
